package com.ruoyi.steelinfo_zz.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.steelinfo_zz.domain.SteelZz;
import com.ruoyi.steelinfo_zz.service.ISteelZzService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 钢材信息管理Controller
 * 
 * @author ruoyi
 * @date 2025-06-16
 */
@Controller
@RequestMapping("/steel_comany/steelinfo")
public class SteelZzController extends BaseController
{
    private String prefix = "steel_comany/steelinfo";

    @Autowired
    private ISteelZzService steelZzService;

    @RequiresPermissions("steel_comany:steelinfo:view")
    @GetMapping()
    public String steelinfo()
    {
        return prefix + "/steelinfo";
    }

    /**
     * 查询钢材信息管理列表
     */
    @RequiresPermissions("steel_comany:steelinfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SteelZz steelZz)
    {
        startPage();
        List<SteelZz> list = steelZzService.selectSteelZzList(steelZz);
        return getDataTable(list);
    }

    /**
     * 导出钢材信息管理列表
     */
    @RequiresPermissions("steel_comany:steelinfo:export")
    @Log(title = "钢材信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SteelZz steelZz)
    {
        List<SteelZz> list = steelZzService.selectSteelZzList(steelZz);
        ExcelUtil<SteelZz> util = new ExcelUtil<SteelZz>(SteelZz.class);
        return util.exportExcel(list, "钢材信息管理数据");
    }

    /**
     * 新增钢材信息管理
     */
    @RequiresPermissions("steel_comany:steelinfo:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存钢材信息管理
     */
    @RequiresPermissions("steel_comany:steelinfo:add")
    @Log(title = "钢材信息管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SteelZz steelZz)
    {
        return toAjax(steelZzService.insertSteelZz(steelZz));
    }

    /**
     * 修改钢材信息管理
     */
    @RequiresPermissions("steel_comany:steelinfo:edit")
    @GetMapping("/edit/{steelId}")
    public String edit(@PathVariable("steelId") Long steelId, ModelMap mmap)
    {
        SteelZz steelZz = steelZzService.selectSteelZzBySteelId(steelId);
        mmap.put("steelZz", steelZz);
        return prefix + "/edit";
    }

    /**
     * 修改保存钢材信息管理
     */
    @RequiresPermissions("steel_comany:steelinfo:edit")
    @Log(title = "钢材信息管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SteelZz steelZz)
    {
        return toAjax(steelZzService.updateSteelZz(steelZz));
    }

    /**
     * 删除钢材信息管理
     */
    @RequiresPermissions("steel_comany:steelinfo:remove")
    @Log(title = "钢材信息管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(steelZzService.deleteSteelZzBySteelIds(ids));
    }
}
